package com.jiao.databinding3.observablefield;

import androidx.databinding.ObservableField;
import androidx.databinding.ObservableFloat;
//对 ObservableGoods 属性值的改变都会立即触发 UI 刷新，概念上与 Observable 区别不大
//可观察字段是具有单个字段的自包含可观察对象。原语版本避免在访问操作期间封箱和开箱。如需使用此机制，
// 请采用 Java 编程语言创建 public final 属性，或在 Kotlin 中创建只读属性
public class ObservableGoods  {
    public final ObservableField<String> name;

    public final ObservableFloat price;

    public final ObservableField<String> details;
//    val loginBtnEnable = object : ObservableBoolean(userName, userPwd) {
//        override fun get(): Boolean {
//            return !userName.get()?.trim().isNullOrEmpty() && !userPwd.get().isNullOrEmpty()
//        }
//    }
    public ObservableGoods(String name, float price, String details) {
        this.name = new ObservableField<>(name);
        this.price = new ObservableFloat(price);
        this.details = new ObservableField<>(details);
    }

}
